package com.qidian.buy.util.pojo;

import com.qidian.buy.util.Constant;

/**
 * Author: 戴着假发的程序员
 * Date: 2023-07-06 10:11
 * company: 起点编程
 * Description:
 **/
// 后端的统一格式的响应结果
public class BuyResult {
    private int code;
    private String msg;
    private Object data;

    public BuyResult(int code) {
        this.code = code;
    }


    public static BuyResult ok(){
        BuyResult result = new BuyResult(Constant.RESPONSE_STATUS_OK,"OK");
        return  result;
    }
    public static BuyResult ok(String msg){
        BuyResult result = new BuyResult(Constant.RESPONSE_STATUS_OK,msg);
        return  result;
    }

    public static BuyResult ok(Object data){
        BuyResult result = new BuyResult(Constant.RESPONSE_STATUS_OK,"OK",data);
        return  result;
    }

    public static BuyResult ok(String msg,Object data){
        BuyResult result = new BuyResult(Constant.RESPONSE_STATUS_OK,msg,data);
        return  result;
    }

    public static BuyResult fail(){
        return new BuyResult(Constant.RESPONSE_STATUS_FAIL);
    }
    public static BuyResult fail(String msg){
        return new BuyResult(Constant.RESPONSE_STATUS_FAIL,msg);
    }
    public static BuyResult fail(String msg,Object data){
        return new BuyResult(Constant.RESPONSE_STATUS_FAIL,msg,data);
    }
    public static BuyResult fail(Object data){
        return new BuyResult(Constant.RESPONSE_STATUS_FAIL,"FAIL",data);
    }



    public BuyResult() {
    }

    public BuyResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BuyResult(String msg, Object data) {
        this.msg = msg;
        this.data = data;
    }

    public BuyResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static BuyResult repeat() {
        return new BuyResult(Constant.RESPONSE_STATUS_REPEAT);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
